package com.quanquan.user.repository;

import com.quanquan.user.entity.UserFormId;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @ClassName:UserFormIdRepository
 * @Description:TODO
 * @Author:xiongjunbao
 * @Date:2019/11/14 17:03
 * @Version 1.0
 */
public interface UserFormIdRepository extends JpaRepository<UserFormId,String>{

    /**
     * 通过openid查找用户formId
     * @param openid
     * @return
     */
    @Query(value = "select * from oo_user_form_id where openid=?1 and state=0 and expire_time > now() order by exprie_time desc limit 1",nativeQuery = true)
    UserFormId findOneFormId(String openid);

}
